****
****
****	Replication File
**** 
****	
****	"The Role of Child Perception and
****	Motivation in Political Socialization"
****
****	Hatemi and Ojeda
****
****
****
****	Table of Contents
****
****	- Figure 2: Plot of Perception/Misperception and Adoption/Reject Levels
****
****	- Figure 3: The Conditional Effect of Politicization on Child Perception
****
****	- Figure 4: The Conditional Effect of Parent-Child Closeness on Child PID
****
****	- Table 2: A Comparison of Direct Transmission to Perception-Adoption
****
****	- Table 3: Examining the Factors that Moderate Direct Transmission of Parental PID
****
****	- Table 4: Examining the Factors that Moderate Perception of Parental PID
****
****	- Table 5: Examining the Factors that Moderate Adoption of Parental PID
****
****	- Supplementary Information:
****
****			- Distribution of PID
****
****			- Descriptive Statistics and Correlations Between Variables
****


****
**** Figure 2: Perception/Misperceptoin and Adoption/Rejection Levels
****

*YPSS Parents
use "ypss_final.dta", clear
gen pid3_ps73 = pid_ps73
recode pid3_ps73 1=1 2=1 3=1 4=2 5=3 6=3 7=3
gen pid3_cs73 = pid_cs73
recode pid3_cs73 1=1 2=1 3=1 4=2 5=3 6=3 7=3
gen pid3_com73 = pid_com73
recode pid3_com73 1=1 2=1 3=1 4=2 5=3 6=3 7=3
gen pid3_cof73 = pid_cof73
recode pid3_cof73 1=1 2=1 3=1 4=2 5=3 6=3 7=3

gen pa_mom73 = 0
replace pa_mom73 = 1 if (pid3_ps73 == pid3_com73)
replace pa_mom73 = 1 if (pid3_ps73 == pid3_com73)
replace pa_mom73 = . if (pid3_ps73 == . | pid3_com73==.)
replace pa_mom73 = . if parent_type != 2
gen pa_dad73 = 0
replace pa_dad73 = 1 if (pid3_ps73 == pid3_cof73)
replace pa_dad73 = . if (pid3_ps73 == . | pid3_cof73==.)
replace pa_dad73 = . if parent_type != 3

gen iw_mom73 = 0
replace iw_mom73 = 1 if (pid3_com73 == pid3_cs73)
replace iw_mom73 = . if (pid3_com73 ==. | pid3_cs73==.)
replace iw_mom73 = . if parent_type != 2
gen iw_dad73 = 0
replace iw_dad73 = 1 if (pid3_cof73 == pid3_cs73)
replace iw_dad73 = . if (pid3_cof73 ==. | pid3_cs73==.)
replace iw_dad73 = . if parent_type != 3

tab iw_mom73 pa_mom73, cell
tab iw_dad73 pa_dad73, cell
tab pid3_cs73 pid3_ps73, cell

*HLS Mothers
use "hls_final.dta", clear
keep if pol_cs != . & pol_ms != . & pol_com != .
svyset FAMID_ANZUS65K
svy: tab mom_table
svy: tab pol_cs3 pol_ms3, cell

*HLS Fathers
use "hls_final.dta", clear
keep if pol_cs != . & pol_fs != . & pol_cof != .
svyset FAMID_ANZUS65K
svy: tab dad_table
svy: tab pol_cs3 pol_fs3, cell

*NLSY Mothers
use "nlsy_final.dta", clear
keep if pol_csa != . & pol_msa != . & pol_coma != .
svyset mom_id [pw = weight_ysamp08]
svy: tab con_table
svy: tab pol_csa pol_msa, cell

**
** Creating graph
clear
set obs 20
gen pid_dist = .

*Perceive and Adoption
replace pid_dist = 51.86 if _n == 1
replace pid_dist = 53.29 if _n == 2
replace pid_dist = 46.49 if _n == 3
replace pid_dist = 46.07 if _n == 4
replace pid_dist = 48.79 if _n == 5

*Perceive and Reject
replace pid_dist = 22.05 if _n == 6
replace pid_dist = 24.03 if _n == 7
replace pid_dist = 23.25 if _n == 8
replace pid_dist = 23.61 if _n == 9
replace pid_dist = 17.95 if _n == 10

*Misperceive and Adopt
replace pid_dist = 13.35 if _n == 11
replace pid_dist = 12.02 if _n == 12
replace pid_dist = 18.55 if _n == 13
replace pid_dist = 18.59 if _n == 14
replace pid_dist = 20.28 if _n == 15

*Misperceive and Reject
replace pid_dist = 12.73 if _n == 16
replace pid_dist = 10.66 if _n == 17
replace pid_dist = 11.71 if _n == 18
replace pid_dist = 11.73 if _n == 19
replace pid_dist = 12.98 if _n == 20

forvalues i=1(1)20{
gen pid_dist`i' = .
replace pid_dist`i' = pid_dist if _n == `i'
}
*

gen n_var = .
replace n_var = 1 if _n == 1
replace n_var = 2 if _n == 2
replace n_var = 3 if _n == 3
replace n_var = 4 if _n == 4
replace n_var = 5 if _n == 5

replace n_var = 7 if _n == 6
replace n_var = 8 if _n == 7
replace n_var = 9 if _n == 8
replace n_var = 10 if _n == 9
replace n_var = 11 if _n == 10

replace n_var = 13 if _n == 11
replace n_var = 14 if _n == 12
replace n_var = 15 if _n == 13
replace n_var = 16 if _n == 14
replace n_var = 17 if _n == 15

replace n_var = 19 if _n == 16
replace n_var = 20 if _n == 17
replace n_var = 21 if _n == 18
replace n_var = 22 if _n == 19
replace n_var = 23 if _n == 20

gen pid_dist_rd = round(pid_dist)
  
twoway (bar pid_dist1 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("247 247 247")) ///
		(bar pid_dist2 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("204 204 204")) ///
		(bar pid_dist3 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("150 150 150")) ///
		(bar pid_dist4 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("99 99 99")) ///
		(bar pid_dist5 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("37 37 37")) ///
		(bar pid_dist6 n_var, barwidth(0.95) lcolor(gs0) lwidth(vthin) fcolor("247 247 247")) ///		
		(bar pid_dist7 n_var, barwidth(0.95) lcolor(gs0) lwidth(vthin) fcolor("204 204 204")) ///
		(bar pid_dist8 n_var, barwidth(0.95) lcolor(gs0) lwidth(vthin) fcolor("150 150 150")) /// 
		(bar pid_dist9 n_var, barwidth(0.95) lcolor(gs0) lwidth(vthin) fcolor("99 99 99")) /// 
		(bar pid_dist10 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("37 37 37")) /// 
		(bar pid_dist11 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("247 247 247")) ///
		(bar pid_dist12 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("204 204 204")) ///
		(bar pid_dist13 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("150 150 150")) ///
		(bar pid_dist14 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("99 99 99")) ///
		(bar pid_dist15 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("37 37 37")) ///
		(bar pid_dist16 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("247 247 247")) ///
		(bar pid_dist17 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("204 204 204")) ///
		(bar pid_dist18 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("150 150 150")) ///
		(bar pid_dist19 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("99 99 99")) ///
		(bar pid_dist20 n_var, barwidth(0.9) lcolor(gs0) lwidth(vthin) fcolor("37 37 37")) ///
		(scatter pid_dist n_var, msymbol(i) mlabel(pid_dist_rd) mlabp(12)), ///
		legend(order(1 2 3 4 5) label(1 "YPSS" "Mothers") label(2 "YPSS" "Fathers")  label(3 "HLS" "Mothers") label(4 "HLS" "Fathers") label(5 "NLSY" "Mothers") rows(1) symxsize(5)) ///
		ylabel(0 10 20 30 40 50 60, labsize(2.5) angle(horizontal) nogrid) ///
		ytitle("Percentage of Children Who...", size(4)) ///
		xlabel(3 `" "Perceive" "and Adopt" "' 9 `" "Perceive" "and Reject" "' 15 `" "Misperceive" "and Adopt" "' 21 `" "Misperceive" "and Reject" "', notick labgap(1)) ///
		xtitle("") ///
		yscale(titlegap(3)) ///
		yline(49, lcolor(gs10) lpattern(dash)) ///
		yline(56, lcolor(gs10) lpattern(dash)) ///
		scheme(s2mono) graphregion(fcolor(white)) ///
		text(51 23 "Average Level of True Transmission", color(gs10) place(w) size(small)) ///
		text(59 23 "Average Level of Trait-to-Trait Transmission", color(gs10) place(w) size(small))

	

****
**** Table 2: A Comparison of Direct Transmission to Perception-Adoption
****		

**
** YPSS
use "ypss_final.dta", clear
ologit pid_cs73 pid_ps73 pid_spouse73 par_female child_female child_nowhite college73 child_inc73 par_degree close att_fold_ps73 part_total73 if pid_cop73 != ., cluster(v5)
ologit pid_cs73 pid_cop73 pid_ps73 pid_spouse73 par_female child_female child_nowhite college73 child_inc73 par_degree close att_fold_ps73 part_total73, cluster(v5)
sgmediation pid_cs73, mv(pid_cop73) iv(pid_ps73) cv(pid_spouse73 par_female child_female child_nowhite college73 child_inc73 par_degree close att_fold_ps73 part_total73)

**
** HLS
use "hls_final.dta", clear
meologit pol_cs pol_ms pol_fs sex_child age_child educ_cs educ_ms educ_fs minc10 soc att_ms_fold att_fs_fold if pol_com != . & pol_cof != . || FAMID_ANZUS65K:
meologit pol_cs pol_com pol_cof pol_ms pol_fs sex_child age_child educ_cs educ_ms educ_fs minc10 soc att_ms_fold att_fs_fold || FAMID_ANZUS65K:
sgmediation pol_cs, mv(pol_com) iv(pol_ms) cv(pol_cof pol_fs sex_child age_child educ_cs educ_ms educ_fs minc10 soc att_ms_fold att_fs_fold)
sgmediation pol_cs, mv(pol_cof) iv(pol_fs) cv(pol_com pol_ms sex_child age_child educ_cs educ_ms educ_fs minc10 soc att_ms_fold att_fs_fold)

**
** NLSY
use "nlsy_final.dta", clear
meologit pol_csa pol_msa race_black race_hisp age_ya08 female educ_grade08 meduc08 mincome08_10 mpol_pol if pol_coma != . || mom_id:
meologit pol_csa pol_coma pol_msa race_black race_hisp age_ya08 female educ_grade08 meduc08 mincome08_10 mpol_pol || mom_id:
sgmediation pol_csa, mv(pol_coma) iv(pol_msa) cv(race_black race_hisp age_ya08 female educ_grade08 meduc08 mincome08_10 mpol_pol )


****
**** Table 3: Examining the Factors that Moderate Direct Transmission of Parental PID
****		

**
** YPSS
use "ypss_final.dta", clear
ologit pid_cs73 c.pid_ps73##c.close c.pid_ps73##c.att_fold_ps73 c.pid_ps73##college73 c.pid_ps73##c.part_total73 pid_spouse73 par_female child_female child_nowhite college73 child_inc73 par_degree close att_fold_ps73 part_total73 if pid_cop73 != ., cluster(v5)

**
** HLS
use "hls_final.dta", clear
sort FAMID_ANZUS65K INDIVIDUAL_ANZUS65K
* Mothers
meologit pol_cs c.pol_ms##c.soc c.pol_ms##c.educ_cs c.pol_ms##c.att_ms_fold pol_fs sex_child age_child educ_cs educ_ms educ_fs minc10 soc att_ms_fold att_fs_fold if pol_cof != . & pol_com != . || FAMID_ANZUS65K:
* Fathers
meologit pol_cs pol_ms c.pol_fs##c.soc c.pol_fs##c.educ_cs c.pol_fs##c.att_fs_fold sex_child age_child educ_cs educ_ms educ_fs minc10 soc att_ms_fold att_fs_fold if pol_cof != . & pol_com != . || FAMID_ANZUS65K:

**
** NLSY
use "nlsy_final.dta", clear
meologit pol_csa c.pol_msa##c.mpol_pol c.pol_msa##c.educ_grade08 female race_black race_hisp age_ya08 educ_grade08 meduc08 mincome08_10 mpol_pol if pol_coma != . || mom_id:


****
**** Table 4: Examining the Factors that Moderate Perception of Parental PID
****

**
** YPSS
use "ypss_final.dta", clear
ologit pid_cop73 c.pid_ps73##c.close c.pid_ps73##c.att_fold_ps73 c.pid_ps73##college73 c.pid_ps73##c.part_total73 pid_spouse73 par_female child_female child_nowhite college73 child_inc73 par_degree close att_fold_ps73 part_total73 if pid_cs73 != ., cluster(v5)

**
** HLS
use "hls_final.dta", clear
sort FAMID_ANZUS65K INDIVIDUAL_ANZUS65K
* Mothers
meologit pol_com c.pol_ms##c.soc c.pol_ms##c.educ_cs c.pol_ms##c.att_ms_fold pol_fs sex_child age_child educ_cs educ_ms educ_fs minc10 soc att_ms_fold att_fs_fold if pol_cof != . & pol_cs != . || FAMID_ANZUS65K:
* Fathers
meologit pol_cof pol_ms c.pol_fs##c.soc c.pol_fs##c.educ_cs c.pol_fs##c.att_fs_fold sex_child age_child educ_cs educ_ms educ_fs minc10 soc att_ms_fold att_fs_fold if pol_com != . & pol_cs != .  || FAMID_ANZUS65K: 

**
** NLSY
use "nlsy_final.dta", clear
meologit pol_coma c.pol_msa##c.mpol_pol c.pol_msa##c.educ_grade08 female race_black race_hisp age_ya08 educ_grade08 meduc08 mincome08_10 mpol_pol if pol_csa != . || mom_id:


****
**** Table 5: Examining the Factors that Moderate Adoption of Parental PID
****

**
** YPSS
use "ypss_final.dta", clear
ologit pid_cs73 c.pid_cop73##c.close c.pid_cop73##c.att_fold_ps73 c.pid_cop73##college73 c.pid_cop73##c.part_total73 pid_spouse73 pid_ps73 par_female child_female child_nowhite college73 child_inc73 par_degree close att_fold_ps73 part_total73, cluster(v5)
		
**
** HLS
use "hls_final.dta", clear
sort FAMID_ANZUS65K INDIVIDUAL_ANZUS65K
* Mothers
meologit pol_cs c.pol_com##c.soc c.pol_com##c.educ_cs c.pol_com##c.att_ms_fold pol_cof pol_ms pol_fs sex_child age_child educ_cs educ_ms educ_fs minc10 soc att_ms_fold att_fs_fold || FAMID_ANZUS65K:
* Fathers
meologit pol_cs pol_com c.pol_cof##c.soc c.pol_cof##c.educ_cs c.pol_cof##c.att_fs_fold pol_ms pol_fs sex_child age_child educ_cs educ_ms educ_fs minc10 soc att_ms_fold att_fs_fold || FAMID_ANZUS65K:

**
** NLSY
use "nlsy_final.dta", clear
meologit pol_csa c.pol_coma##c.mpol_pol c.pol_coma##c.educ_grade08 pol_msa female race_black race_hisp age_ya08 educ_grade08 meduc08 mincome08_10 mpol_pol || mom_id:


****
**** Figure 3: The Conditional Effect of Politicization on Child Perception
****

use "nlsy_final.dta", clear
meologit pol_coma c.pol_msa##c.mpol_pol c.pol_msa##c.educ_grade08 female race_black race_hisp age_ya08 educ_grade08 meduc08 mincome08_10 mpol_pol if pol_csa != . || mom_id:
margins , at(pol_msa=(1 2 3) mpol_pol=(-1.853971 1.500229)) predict(mu outcome(3)) atmeans
matrix A = r(table)'
svmat A, names(nlsy_pol)
gen nlsy_pol = .
replace nlsy_pol = 0 if _n == 1 | _n == 3 | _n == 5
replace nlsy_pol = 1 if _n == 2 | _n == 4 | _n == 6
gen nlsy_pid = .
replace nlsy_pid = 1 if _n == 1 | _n == 2
replace nlsy_pid = 2 if _n == 3 | _n == 4
replace nlsy_pid = 3 if _n == 5 | _n == 6
gen nlsy_pid2 = .
replace nlsy_pid2 = nlsy_pid - .05 if nlsy_pol == 0
replace nlsy_pid2 = nlsy_pid + .05 if nlsy_pol == 1

graph twoway (rspike nlsy_pol5 nlsy_pol6 nlsy_pid2 if nlsy_pol == 0, lcolor(black) lwidth(med)) ///
			(rspike nlsy_pol5 nlsy_pol6 nlsy_pid2 if nlsy_pol == 1, lcolor(black) lwidth(med)) ///
			(scatter nlsy_pol1 nlsy_pid2 if nlsy_pol == 0, msymbol(O) msize(medlarge) mfcolor(white) mlcolor(black)) ///
			(scatter nlsy_pol1 nlsy_pid2 if nlsy_pol == 1, msymbol(O) msize(medlarge) mfcolor(black) mlcolor(black)), ///
			legend(order(3 4) label(3 "Low Politicization") label(4 "High Politicization") rows(2) symxsize(5) ring(0) position (11) region(lcolor(white))) ///
			xtitle("NLSY Parent PID") ///
			ytitle("Predicted Probability") ///
			xlabel(1 "Democrat" 2 "Independent" 3 "Republican", labsize(2.5) notick labgap(1)) ///
			ylabel(0 .2 .4 .6 .8 1.0, nogrid labsize(2.5) angle(horizontal)) ///
			yscale(titlegap(2)) ///
			xscale(titlegap(2.5)) ///
			scheme(s1mono) graphregion(fcolor(white)) ///
			name(nlsy_pol, replace)

use "ypss_final.dta", clear
ologit pid_cop73 c.pid_ps73##c.close c.pid_ps73##c.att_fold_ps73 c.pid_ps73##college73 c.pid_ps73##c.part_total73 pid_spouse73 par_female child_female child_nowhite college73 child_inc73 par_degree close att_fold_ps73 part_total73 if pid_cs73 != ., cluster(v5)
margins , at(pid_ps73=(1 2 3 4 5 6 7) part_total73=(0 1)) predict(outcome(7)) atmeans
matrix B = r(table)'
svmat B, names(ypss_pol)
gen ypss_pol = .
replace ypss_pol = 0 if _n == 1 | _n == 3 | _n == 5 | _n == 7 | _n == 9 | _n == 11 | _n == 13
replace ypss_pol = 1 if _n == 2 | _n == 4 | _n == 6 | _n == 8 | _n == 10 | _n == 12 | _n == 14
gen ypss_pid = .
replace ypss_pid = 1 if _n == 1 | _n == 2
replace ypss_pid = 2 if _n == 3 | _n == 4
replace ypss_pid = 3 if _n == 5 | _n == 6
replace ypss_pid = 4 if _n == 7 | _n == 8
replace ypss_pid = 5 if _n == 9 | _n == 10
replace ypss_pid = 6 if _n == 11 | _n == 12
replace ypss_pid = 7 if _n == 13 | _n == 14
gen ypss_pid2 = .
replace ypss_pid2 = ypss_pid - .05 if ypss_pol == 0
replace ypss_pid2 = ypss_pid + .05 if ypss_pol == 1

graph twoway (rspike ypss_pol5 ypss_pol6 ypss_pid2 if ypss_pol == 0, lcolor(black) lwidth(med)) ///
			(rspike ypss_pol5 ypss_pol6 ypss_pid2 if ypss_pol == 1, lcolor(black) lwidth(med)) ///
			(scatter ypss_pol1 ypss_pid2 if ypss_pol == 0, msymbol(O) msize(medlarge) mfcolor(white) mlcolor(black)) ///
			(scatter ypss_pol1 ypss_pid2 if ypss_pol == 1, msymbol(O) msize(medlarge) mfcolor(black) mlcolor(black)), ///
			legend(order(3 4) label(3 "Low Politicization") label(4 "High Politicization") rows(2) symxsize(5) ring(0) position (11) region(lcolor(white))) ///
			xtitle("YPSS Parent PID") ///
			ytitle("Predicted Probability") ///
			xlabel(1 `""Strong" "Democrat""' 2 "Democrat" 3 `""Lean" "Democrat""' 4 "Independent" 5 `""Lean" "Republican""' 6 "Republican" 7  `""Strong" "Republican""' , labsize(2.5) notick labgap(1)) ///
			ylabel(0 .2 .4 .6 .8 1.0, nogrid labsize(2.5) angle(horizontal)) ///
			yscale(titlegap(2)) ///
			xscale(titlegap(2.5)) ///
			scheme(s1mono) graphregion(fcolor(white)) ///
			name(ypss_pol, replace)

graph combine ypss_pol nlsy_pol, ///
		title(Probability of Perceiving a (Strong) Republican Parent) ///
		scheme(s2mono) ///
		graphregion(color(white)) ///
		plotregion(color(white))

		
****
**** Figure 4: The Conditional Effect of Parent-Child Closeness on Child PID
****

use "hls_final.dta", clear
sort FAMID_ANZUS65K INDIVIDUAL_ANZUS65K
meologit pol_cs c.pol_com##c.soc c.pol_com##c.educ_cs c.pol_com##c.att_ms_fold pol_cof pol_ms pol_fs sex_child age_child educ_cs educ_ms educ_fs minc10 soc att_ms_fold att_fs_fold || FAMID_ANZUS65K:
margins , at(pol_com=(1 2 3 4 5) soc=(0 12)) predict(outcome(5)) atmeans
matrix B = r(table)'
svmat B, names(hls_soc)
gen hls_soc = .
replace hls_soc = 0 if _n == 1 | _n == 3 | _n == 5 | _n == 7 | _n == 9
replace hls_soc = 1 if _n == 2 | _n == 4 | _n == 6 | _n == 8 | _n == 10
gen hls_pid = .
replace hls_pid = 1 if _n == 1 | _n == 2
replace hls_pid = 2 if _n == 3 | _n == 4
replace hls_pid = 3 if _n == 5 | _n == 6
replace hls_pid = 4 if _n == 7 | _n == 8
replace hls_pid = 5 if _n == 9 | _n == 10
gen hls_pid2 = .
replace hls_pid2 = hls_pid - .05 if hls_soc == 0
replace hls_pid2 = hls_pid + .05 if hls_soc == 1

graph twoway (rspike hls_soc5 hls_soc6 hls_pid2 if hls_soc == 0, lcolor(black) lwidth(med)) ///
			(rspike hls_soc5 hls_soc6 hls_pid2 if hls_soc == 1, lcolor(black) lwidth(med)) ///
			(scatter hls_soc1 hls_pid2 if hls_soc == 0, msymbol(O) msize(medsmall) mfcolor(white) mlcolor(black)) ///
			(scatter hls_soc1 hls_pid2 if hls_soc == 1, msymbol(O) msize(medsmall) mfcolor(black) mlcolor(black)), ///
			legend(order(3 4) label(3 "Not Close") label(4 "Very Close") rows(2) symxsize(5) ring(0) position (11) region(lcolor(white))) ///
			xtitle("HLS Mother PID") ///
			ytitle("Predicted Probability") ///
			xlabel(1 `""Always" "Democrat""' 2  `""Usually" "Democrat""'  3 "Varies" 4  `""Usually" "Republican""'  5 `""Always" "Republican""' , labsize(2.5) notick labgap(1)) ///
			ylabel(0 .2 .4 .6 .8 1.0, nogrid labsize(2.5) angle(horizontal)) ///
			yscale(titlegap(2)) ///
			xscale(titlegap(2.5)) ///
			scheme(s1mono) graphregion(fcolor(white)) ///
			name(hls_soc, replace)

use "ypss_final.dta", clear
ologit pid_cs73 c.pid_cop73##c.close c.pid_cop73##c.att_fold_ps73 c.pid_cop73##college73 c.pid_cop73##c.part_total73 pid_spouse73 pid_ps73 par_female child_female child_nowhite college73 child_inc73 par_degree close att_fold_ps73 part_total73, cluster(v5)
margins , at(pid_cop73=(1 2 3 4 5 6 7) close=(0 3.25)) predict(outcome(7)) atmeans
matrix B = r(table)'
svmat B, names(ypss_soc)
gen ypss_soc = .
replace ypss_soc = 0 if _n == 1 | _n == 3 | _n == 5 | _n == 7 | _n == 9 | _n == 11 | _n == 13
replace ypss_soc = 1 if _n == 2 | _n == 4 | _n == 6 | _n == 8 | _n == 10 | _n == 12 | _n == 14
gen ypss_pid = .
replace ypss_pid = 1 if _n == 1 | _n == 2
replace ypss_pid = 2 if _n == 3 | _n == 4
replace ypss_pid = 3 if _n == 5 | _n == 6
replace ypss_pid = 4 if _n == 7 | _n == 8
replace ypss_pid = 5 if _n == 9 | _n == 10
replace ypss_pid = 6 if _n == 11 | _n == 12
replace ypss_pid = 7 if _n == 13 | _n == 14
gen ypss_pid2 = .
replace ypss_pid2 = ypss_pid - .05 if ypss_soc == 0
replace ypss_pid2 = ypss_pid + .05 if ypss_soc == 1

graph twoway (rspike ypss_soc5 ypss_soc6 ypss_pid2 if ypss_soc == 0, lcolor(black) lwidth(med)) ///
			(rspike ypss_soc5 ypss_soc6 ypss_pid2 if ypss_soc == 1, lcolor(black) lwidth(med)) ///
			(scatter ypss_soc1 ypss_pid2 if ypss_soc == 0, msymbol(O) msize(medlarge) mfcolor(white) mlcolor(black)) ///
			(scatter ypss_soc1 ypss_pid2 if ypss_soc == 1, msymbol(O) msize(medlarge) mfcolor(black) mlcolor(black)), ///
			legend(order(3 4) label(3 "Not Close") label(4 "Very Close") rows(2) symxsize(5) ring(0) position (11) region(lcolor(white))) ///
			xtitle("YPSS Parent PID") ///
			ytitle("Predicted Probability") ///
			xlabel(1 `""Strong" "Democrat""' 2 "Democrat" 3 `""Lean" "Democrat""' 4 "Independent" 5 `""Lean" "Republican""' 6 "Republican" 7  `""Strong" "Republican""' , labsize(2.5) notick labgap(1)) ///
			ylabel(0 .2 .4 .6 .8 1.0, nogrid labsize(2.5) angle(horizontal)) ///
			yscale(titlegap(2)) ///
			xscale(titlegap(2.5)) ///
			scheme(s1mono) graphregion(fcolor(white)) ///
			name(ypss_soc, replace)
		
graph combine ypss_soc hls_soc, ///
		title(Probability of Identifying as Strong/Always Republican ) ///
		scheme(s2mono) ///
		graphregion(color(white)) ///
		plotregion(color(white))


********************************************************************************
**** SUPPLEMENTARY INFORMATION

****
**** Distribution of PID across datasets
**** 

**
** YPSS PID Distribution
use "ypss_final.dta", clear
tab1 pid_cs73
tab1 pid_ps73
tab1 pid_cop73 

tab1 pid_cs73, missing
tab1 pid_ps73, missing
tab1 pid_cop73 , missing

clear
set obs 21

gen pid_dist = .
replace pid_dist = 8.59 if _n == 1
replace pid_dist = 24.72 if _n == 2
replace pid_dist = 16.06 if _n == 3
replace pid_dist = 19.86 if _n == 4
replace pid_dist = 12.33 if _n == 5
replace pid_dist = 12.27 if _n == 6
replace pid_dist = 5.81 if _n == 7
replace pid_dist = 17.12 if _n == 8
replace pid_dist = 26.24 if _n == 9
replace pid_dist = 8.90 if _n == 10
replace pid_dist = 10.90 if _n == 11
replace pid_dist = 6.82 if _n == 12
replace pid_dist = 17.57 if _n == 13
replace pid_dist = 12.45 if _n == 14
replace pid_dist = 22.92 if _n == 15
replace pid_dist = 21.53 if _n == 16
replace pid_dist = 4.53 if _n == 17
replace pid_dist = 9.27 if _n == 18
replace pid_dist = 5.91 if _n == 19
replace pid_dist = 16.86 if _n == 20
replace pid_dist = 18.98 if _n == 21

forvalues i=1(1)21{
gen pid_dist`i' = .
replace pid_dist`i' = pid_dist if _n == `i'
}
*

gen n_var = .
replace n_var = 1 if _n == 1
replace n_var = 2 if _n == 8
replace n_var = 3 if _n == 15
replace n_var = 5 if _n == 2
replace n_var = 6 if _n == 9
replace n_var = 7 if _n == 16
replace n_var = 9 if _n == 3
replace n_var = 10 if _n == 10
replace n_var = 11 if _n == 17
replace n_var = 13 if _n == 4
replace n_var = 14 if _n == 11
replace n_var = 15 if _n == 18
replace n_var = 17 if _n == 5
replace n_var = 18 if _n == 12
replace n_var = 19 if _n == 19
replace n_var = 21 if _n == 6
replace n_var = 22 if _n == 13
replace n_var = 23 if _n == 20
replace n_var = 25 if _n == 7
replace n_var = 26 if _n == 14
replace n_var = 27 if _n == 21

twoway (bar pid_dist1 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist2 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist3 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist4 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist5 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist6 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///		
		(bar pid_dist7 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist8 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) /// 
		(bar pid_dist9 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) /// 
		(bar pid_dist10 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) /// 
		(bar pid_dist11 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) ///
		(bar pid_dist12 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) ///
		(bar pid_dist13 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) ///
		(bar pid_dist14 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) ///
		(bar pid_dist15 n_var, barwidth(0.95) lcolor(black) color("117 112 179")) ///
		(bar pid_dist16 n_var, barwidth(0.95) lcolor(black) color("117 112 179")) ///
		(bar pid_dist17 n_var, barwidth(0.95) lcolor(black) color("117 112 179")) ///
		(bar pid_dist18 n_var, barwidth(0.95) lcolor(black) color("117 112 179")) ///
		(bar pid_dist19 n_var, barwidth(0.95) lcolor(black) color("117 112 179")) ///
		(bar pid_dist20 n_var, barwidth(0.95) lcolor(black) color("117 112 179")) ///
		(bar pid_dist21 n_var, barwidth(0.95) lcolor(black) color("117 112 179")), ///
		legend(order(1 8 15) label(1 "Child Self-Report") label(8 "Parent Self-Report") label(15 "Child Parent-Report") rows(1) symxsize(4)) ///	
		ylabel(0 5 10 15 20 25, labsize(2.5) angle(horizontal)) ///
		ytitle("Percent Reporting", size(4)) ///
		xlabel(2 "Strong Democrat" 6 "Democrat" 10 "Lean Democrat" 14 "Independent" 18 "Lean Republican" 22 "Republican" 26 "Strong Republican", notick angle(45) labgap(3)) ///
		xtitle("") ///
		title("Youth-Parent Socialization Study") ///
		scheme(s2mono) graphregion(fcolor(white)) ///
		name(ypss_pid_dist, replace)

**
** HLS PID distribution
use "hls_final.dta", clear
tab1 pol_cs pol_ms pol_com pol_fs pol_cof
tab1 pol_cs pol_ms pol_com pol_fs pol_cof, missing

clear
set obs 25

gen pid_dist = .
replace pid_dist = 5.78 if _n == 1
replace pid_dist = 19.37 if _n == 2
replace pid_dist = 34.66 if _n == 3
replace pid_dist = 27.60 if _n == 4
replace pid_dist = 12.59 if _n == 5
replace pid_dist = 6.22 if _n == 6
replace pid_dist = 20.11 if _n == 7
replace pid_dist = 34.97 if _n == 8
replace pid_dist = 25.07 if _n == 9
replace pid_dist = 13.63 if _n == 10
replace pid_dist = 11.74 if _n == 11
replace pid_dist = 25.38 if _n == 12
replace pid_dist = 21.65 if _n == 13
replace pid_dist = 24.95 if _n == 14
replace pid_dist = 16.28 if _n == 15
replace pid_dist = 6.02 if _n == 16
replace pid_dist = 17.36 if _n == 17
replace pid_dist = 33.74 if _n == 18
replace pid_dist = 29.24 if _n == 19
replace pid_dist = 13.64 if _n == 20
replace pid_dist = 14.75 if _n == 21
replace pid_dist = 23.57 if _n == 22
replace pid_dist = 18.14 if _n == 23
replace pid_dist = 24.66 if _n == 24
replace pid_dist = 18.89 if _n == 25

forvalues i=1(1)25{
gen pid_dist`i' = .
replace pid_dist`i' = pid_dist if _n == `i'
}
*

gen n_var = .
replace n_var = 1 if _n == 1
replace n_var = 2 if _n == 6
replace n_var = 3 if _n == 11
replace n_var = 4 if _n == 16
replace n_var = 5 if _n == 21
replace n_var = 7 if _n == 2
replace n_var = 8 if _n == 7
replace n_var = 9 if _n == 12
replace n_var = 10 if _n == 17
replace n_var = 11 if _n == 22
replace n_var = 13 if _n == 3
replace n_var = 14 if _n == 8
replace n_var = 15 if _n == 13
replace n_var = 16 if _n == 18
replace n_var = 17 if _n == 23
replace n_var = 19 if _n == 4
replace n_var = 20 if _n == 9
replace n_var = 21 if _n == 14
replace n_var = 22 if _n == 19
replace n_var = 23 if _n == 24
replace n_var = 25 if _n == 5
replace n_var = 26 if _n == 10
replace n_var = 27 if _n == 15
replace n_var = 28 if _n == 20
replace n_var = 29 if _n == 25

twoway (bar pid_dist1 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist2 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist3 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist4 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist5 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist6 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) ///
		(bar pid_dist7 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) ///
		(bar pid_dist8 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) ///
		(bar pid_dist9 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) ///
		(bar pid_dist10 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) ///
		(bar pid_dist11 n_var, barwidth(0.95) lcolor(black) color("117 112 179")) ///
		(bar pid_dist12 n_var, barwidth(0.95) lcolor(black) color("117 112 179")) ///
		(bar pid_dist13 n_var, barwidth(0.95) lcolor(black) color("117 112 179")) ///
		(bar pid_dist14 n_var, barwidth(0.95) lcolor(black) color("117 112 179")) ///
		(bar pid_dist15 n_var, barwidth(0.95) lcolor(black) color("117 112 179")) ///
		(bar pid_dist16 n_var, barwidth(0.95) lcolor(black) color("231 41 138")) ///
		(bar pid_dist17 n_var, barwidth(0.95) lcolor(black) color("231 41 138")) ///
		(bar pid_dist18 n_var, barwidth(0.95) lcolor(black) color("231 41 138")) ///
		(bar pid_dist19 n_var, barwidth(0.95) lcolor(black) color("231 41 138")) ///
		(bar pid_dist20 n_var, barwidth(0.95) lcolor(black) color("231 41 138")) ///
		(bar pid_dist21 n_var, barwidth(0.95) lcolor(black) color("102 166 30")) ///
		(bar pid_dist22 n_var, barwidth(0.95) lcolor(black) color("102 166 30")) ///
		(bar pid_dist23 n_var, barwidth(0.95) lcolor(black) color("102 166 30")) ///
		(bar pid_dist24 n_var, barwidth(0.95) lcolor(black) color("102 166 30")) ///
		(bar pid_dist25 n_var, barwidth(0.95) lcolor(black) color("102 166 30")), ///
		legend(order(1 6 11 16 21) label(1 "Child" "Self-Report") label(6 "Mother" "Self-Report") label(11 "Father" "Self-Report") label(16 "Child" "Mother-Report") label(21 "Child" "Father-Report") rows(2) symxsize(4)) ///
		ylabel(0 10 20 30 40, labsize(2.5) angle(horizontal)) ///
		ytitle("Percent Reporting", size(4)) ///
		xlabel(3 `""Always" "Democrat""' 9 `""Usually" "Democrat""' 15 "Varies" 21 `""Usually" "Republican""' 27 `""Always" "Republican""') ///
		xtitle("") ///
		title("Health & Lifestyle Study") ///
		scheme(s2mono) graphregion(fcolor(white)) ///
		name(hls_pid_dist, replace)

**
** NLSY PID distribution
use "nlsy_final.dta", clear
tab1 pol_csa pol_msa pol_coma
tab1 pol_csa pol_msa pol_coma, missing

clear
set obs 9

gen pid_dist = .
replace pid_dist = 47.05 if _n == 1
replace pid_dist = 31.98 if _n == 2
replace pid_dist = 20.97 if _n == 3
replace pid_dist = 55.38 if _n == 4
replace pid_dist = 20.02 if _n == 5
replace pid_dist = 24.60 if _n == 6
replace pid_dist = 55.96 if _n == 7
replace pid_dist = 18.44 if _n == 8
replace pid_dist = 25.60 if _n == 9

forvalues i=1(1)9{
gen pid_dist`i' = .
replace pid_dist`i' = pid_dist if _n == `i'
}
*

gen n_var = .
replace n_var = 1 if _n == 1
replace n_var = 2 if _n == 4
replace n_var = 3 if _n == 7
replace n_var = 5 if _n == 2
replace n_var = 6 if _n == 5
replace n_var = 7 if _n == 8
replace n_var = 9 if _n == 3
replace n_var = 10 if _n == 6
replace n_var = 11 if _n == 9

twoway (bar pid_dist1 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist2 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist3 n_var, barwidth(0.95) lcolor(black) color("27 158 119")) ///
		(bar pid_dist4 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) ///
		(bar pid_dist5 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) ///
		(bar pid_dist6 n_var, barwidth(0.95) lcolor(black) color("217 95 2")) ///		
		(bar pid_dist7 n_var, barwidth(0.95) lcolor(black) color("117 112 179")) ///
		(bar pid_dist8 n_var, barwidth(0.95) lcolor(black) color("117 112 179")) /// 
		(bar pid_dist9 n_var, barwidth(0.95) lcolor(black) color("117 112 179")), /// 
		legend(order(1 4 7) label(1 "Child" "Self-Report") label(4 "Mother" "Self-Report") label(7 "Child" "Mother-Report") rows(1) symxsize(4)) ///
		ylabel(0 10 20 30 40 50 60, labsize(2.5) angle(horizontal)) ///
		ytitle("Percent Reporting", size(4)) ///
		xlabel(2 "Democrat" 6 "Independent" 10 "Republican",) ///
		xtitle("") ///
		title("National Longitudinal Study of Youth") ///
		scheme(s2mono) graphregion(fcolor(white)) ///
		name(nlsy_pid_dist, replace)

		
		
****
**** Descriptive Statistics and Correlations Between Variables
****		

**
** YPSS
use "ypss_final.dta", clear
egen nmis=rowmiss(pid_cs73 pid_ps73 pid_cop73 pid_spouse73 par_female child_female child_nowhite college73 child_inc73 par_degree close att_fold_ps73 part_total73)
sum pid_cs73 pid_ps73 pid_cop73 pid_spouse73  ///
par_female child_female child_nowhite college73 child_inc73 par_degree ///
close att_fold_ps73 part_total73 if nmis == 0
corr pid_cs73 pid_ps73 pid_cop73 pid_spouse73  ///
par_female child_female child_nowhite college73 child_inc73 par_degree ///
close att_fold_ps73 part_total73 if nmis==0
alpha att1_clean73 att2_clean73 att3_clean73 att4_clean73 att5_clean73, std item
alpha par_vote73 part1_ps73 part2_ps73 part3_ps73 part4_ps73 part5_ps73, std item
alpha close_cof65 close_com65 close_cof73 close_com73, std item

**
** HLS
use "hls_final.dta", clear
egen nmis=rowmiss(pol_cs pol_ms pol_fs pol_com pol_cof sex_child age_child educ_cs educ_ms educ_fs minc10 soc att_ms_fold att_fs_fold)
sum pol_cs pol_ms pol_fs pol_com pol_cof ///
sex_child age_child educ_cs educ_ms educ_fs minc10 ///
soc att_ms_fold att_fs_fold if nmis==0
corr pol_cs pol_ms pol_fs pol_com pol_cof ///
sex_child age_child educ_cs educ_ms educ_fs minc10 ///
soc att_ms_fold att_fs_fold if nmis==0
alpha soc4 soc10 soc15, std item

**
** NLSY
use "nlsy_final.dta", clear
egen nmis=rowmiss(pol_csa pol_coma pol_msa race_black race_hisp age_ya08 female educ_grade08 meduc08 mincome08 mpol_pol)
sum pol_csa pol_coma pol_msa ///
race_black race_hisp age_ya08 female educ_grade08 meduc08 mincome08 mpol_pol if nmis == 0
corr pol_csa pol_coma pol_msa ///
race_black race_hisp age_ya08 female educ_grade08 meduc08 mincome08 mpol_pol if nmis == 0
